package com.qf.compusdemo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.compusdemo.dao.FbDao;
import com.qf.compusdemo.entity.Fb;
import com.qf.compusdemo.service.FbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class FbServiceImpl extends ServiceImpl<FbDao, Fb> implements FbService {

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    private FbDao fbdao;

    @Override
    public IPage<Fb> getAllBullet(Page<Fb> pp, Fb bb) {

        QueryWrapper wrapper=new QueryWrapper();
        if(bb.getGgmessage()!=null){
            wrapper.like("ggmessage",bb.getGgmessage());
        }
        wrapper.eq("types",bb.getTypes());
        wrapper.eq("waits",0);
        IPage<Fb> ipage=fbdao.selectPage(pp,wrapper);
//        IPage<Fb> ipage=fbdao.seleceAll(pp,bb);
        return ipage;
    }

    @Override
    public int adddb(Integer[] ids) {
        int a=0;
        for(int i=0;i<ids.length;i++){
             a=fbdao.updateWait(ids[i]);
        }
        return a;
    }

    @Override
    public int insertFb(Fb ff) {
        return fbdao.insertFb(ff);
    }

    @Override
    public IPage<Fb> getPages(Page<Fb> page,String uname) {
        QueryWrapper<Fb> wrapper=new QueryWrapper<>();
        wrapper.eq("uname",uname);
        IPage<Fb> ipage=fbdao.selectPage(page,wrapper);
        return ipage;
    }

    @Override
    public int delFb(Integer[] ids) {
        List lists=java.util.Arrays.asList(ids);
        return fbdao.deleteBatchIds(lists);
    }
}
